from codex import * import random from time import sleep die = ['1', '2', '3', '4', '5', '6'] display.print('To roll the dice...Player 1: Press Button A. Player 2: Press Button B.') sleep(1) display.clear() def turn_rect(): #function to draw a turned rectangle display.draw_line(25, 108, 122, 15, (255,255,255)) #Documentation says color is optional, but display.draw_line(122, 15, 220, 108, (255,255,255)) #the code throws an error without the default color. display.draw_line(220, 108, 122, 200, (255,255,255)) display.draw_line(122, 200, 25, 108, (255,255,255)) def roll_animation(): delay = 0.05 loops = 0 while loops < 5: loops = loops + 1 display.draw_rect(45, 25, 155, 165, (255,255,255)) display.clear() turn_rect() #function turn_rect() called display.clear() delay = delay + 0.005 sleep(delay) while True: if buttons.was_pressed(BTN_A): roll_animation() display.clear() display.draw_rect(45, 25, 155, 165, (110,255,0)) display.draw_text(random.choice(die), scale=20, x=70, y=40) sleep(1) display.clear() if buttons.was_pressed(BTN_B): roll_animation() display.clear() display.draw_rect(45, 25, 155, 165, (255,0,255)) display.draw_text(random.choice(die), scale=20, x=70, y=40) sleep(1) display.clear()